<?php
$this->breadcrumbs=array(
    'Looking For People'
);
$jobseekerList = $data['data'];
$maxPage = $data['MaxPage'];
?>
<div class="">
    <h1>Looking For People</h1>
<!--    <div class="text-center">
    <img src="images/main_2.jpg" alt="" width="560" height="180" class="firstChild lastChild empty">
    </div>-->
    <div class="panel panel-default" style=" background-color: ghostwhite; ">
        <div class="panel-body">
            <h4>Searching condition</h4>
            <form action="index.php?lang=<?= $lang ?>&r=Jobseeker/List" method="get" id="formSearch">
            <input type="hidden" name="lang" value="<?=$lang?>">
            <input type="hidden" name="r" value="<?=$_GET['r']?>">
            <div class="input">
                <!--<input class="span10" id="appendedInputButtons" type="text">-->
                <div class="span8">
                    <label class="control-label" for="inputKeyword"><b>Keyword:</b></label>
                    <input type="search" name="Keyword" id="inputKeyword" class="span12">
                </div>
                <div class="span4">
                    <label class="control-label" for="inputStaffID"><b>Staff ID:</b></label>
                    <input type="text" name="StaffID" id="inputStaffID" class="span12">
                </div>
            </div>
            <div>
<!--                Select the job category :
                <select class="span10" style=" display: block; ">
                    <option value="">-- All job category --</option>
                    <option value="00001">Accounting</option>
                    <option value="00002">Admin / Secretarial</option>
                    <option value="00003">Customer Service</option>
                    <option value="00018">Design / Decorative / Architect</option>
                    <option value="00004">Engineering</option>
                    <option value="00005">Finance</option>
                    <option value="00019">Government Affair</option>
                    <option value="00006">Human Resource</option>
                    <option value="00007">Information Technology</option>
                    <option value="00017">Insurance</option>
                    <option value="00008">Legal / Compliance</option>
                    <option value="00009">Marketing / PR</option>
                    <option value="00020">Medical &amp; Science</option>
                    <option value="00010">Purchasing / Procurement / Expenditure / Buyer / Merchandiser</option>
                    <option value="00012">Sales</option>
                    <option value="00013">Supply Chain / Logistics</option>
                    <option value="00014">Technical / Manufacturing</option>
                    <option value="00015">Top Management</option>
                    <option value="00016">Others</option>
                </select>-->
                <div class="span12">
                    <label class="control-label" for="inputProvince"><b>Select location:</b></label>
                    <select class="span12" name="Province" id="inputProvince">
                        <option selected="selected" value="0"></option>
                        <?= GM::getOptionDropdownProvince($lang) ?>
                    </select>
                </div>
            </div>
            <div class="text-center">
                <button class="btn btn-large btn-danger" type="button" id="btn-search"><i class="icon-search"></i> Search</button>
            </div>
            </form>
        </div>
    </div>
    <!-- begin job list -->
    <div id="staff-list">
        <?php 
            if(empty($jobseekerList)){
                echo '<div class="well well-small">No Data ..</div>';
            }
            
            foreach ($jobseekerList as $row) {
            $edu = $row['PageLanguage'] == 'en'?JobSeeker::getEducationEN($row['Education']):JobSeeker::getEducationTH($row['Education']);
            $Edu = $row['Institution'].' - '.$edu.' '.$row['Major'];
            $LangSkill = '';
            if($row['EnSkill'] >=3 ){
                $LangSkill .= "English: ";
                $LangSkill .= $row['PageLanguage'] == 'en'?JobSeeker::getLanguageSkillEN($row['EnSkill']):JobSeeker::getLanguageSkillTH($row['EnSkill']);
            }
            if($row['JpSkill'] >=3 ){
                $LangSkill .= $LangSkill!=''?'<br>':'';
                $LangSkill .= "Japanese: ";
                $LangSkill .= $row['PageLanguage'] == 'en'?JobSeeker::getLanguageSkillEN($row['JpSkill']):JobSeeker::getLanguageSkillTH($row['JpSkill']);
            }
            ?>
        <div class="jobseeker-box">
            <div class="alert alert-<?= $row['Gender'] == 'M'?'info':'error' ?>">
                <img src="images/001_<?= $row['Gender'] ?>.png">
                <b><span><?= $row['Gender'] == 'M'?'Male':'Female' ?> (<?= GM::findYear($row['DOB'], date("Y-m-d")) ?> years old) : <?= $row['Nationality'] ?></span>
                <span class="pull-right">Staff ID : <?= $row['StaffID'] ?></span></b>
            </div>
            <table class="table table-bordered">
                <tbody>
                    <tr><td class="rowheader">Education:</td><td><?= $Edu ?></td></tr>
                    <tr><td class="rowheader">Language:</td><td><?= $LangSkill ?></td></tr>
                    <tr><td class="rowheader">Desired Job Position:</td><td><?= $row['ExpectWorkingPosition'] ?></td></tr>
                    <tr><td class="rowheader">Hope Salary:</td><td><?= $row['ExpectSalary'] ?></td></tr>
                    <tr><td class="rowheader">Work location:</td><td><?= $row['ExpectLocationName'] ?></td></tr>
                </tbody>
            </table>
            <p class="text-center">
                <a href="index.php?lang=<?= $lang ?>&r=Jobseeker/Detail&id=<?= $row['StaffID'] ?>" class="btn btn-large btn-primary" style="color: #fff;">
                    <i class="icon-list-alt"></i> Detail
                </a>
            </p>
        </div>
        <hr>
        <?php } ?>
    </div>
    <!-- End of job list -->
    <!--PAGE-->
    <?php
    if(isset($_GET['Keyword']) || isset($_GET['StaffID']) || isset($_GET['Province'])){
        $url = "index.php?lang=en&r=Jobseeker/List&Keyword={$_GET['Keyword']}&StaffID={$_GET['StaffID']}&Province={$_GET['Province']}&";
    } else {
        $url = "index.php?lang=en&r=Jobseeker/List&";
    }
    GM::paging($url, $page, $maxPage); ?>  				 
    <!--End Contact form -->											 
</div>
<script>
    $(function(){
        // get value in form search
        $('#inputKeyword').val('<?= isset($_GET['Keyword']) ? $_GET['Keyword'] : '' ?>');
        $('#inputStaffID').val('<?= isset($_GET['StaffID']) ? $_GET['StaffID'] : '' ?>');
        $('#inputProvince').val('<?= isset($_GET['Province']) ? $_GET['Province'] : '' ?>');
        
        //fill '-' cell(td)empty
        $('td').each(function(){
            if($(this).text()==''){
                $(this).text('-');
            }
        });
        
        $('#btn-search').click(function(){
            document.getElementById("formSearch").submit();
        });
    });
</script>